package 内存可见性复习;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-10-06
 * Time: 16:30
 */
class Count{
      public int count = 0;
}
public class demo1 {

    public static void main(String[] args) {
        Count count = new Count();
        Thread t = new Thread(){
            @Override
            public void run() {
                while (count.count == 0){
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("t线程结束");
            }
        };
        t.start();
        Thread t1 = new Thread(){
            @Override
            public void run() {
                System.out.println("请输入数字:");
                Scanner scanner = new Scanner(System.in);
                count.count = scanner.nextInt();
            }
        };

        t1.start();
    }

}
